package bktech.soict.hust.bknote.activity.sms;

import bktech.soict.hust.bknote.R;
import bktech.soict.hust.bknote.sendsms.SmsSend;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class SendSMS extends Activity{
	private EditText etEnterPhoneNumber, etEnterMessage;
	private SmsSend manager;
	private OnClickListener clickListener = new OnClickListener() {

		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.btSendSMS:
				
				manager.send(etEnterPhoneNumber.getText().toString(),
						etEnterMessage.getText().toString());
				break;
			case R.id.btSendSMSWtihListenBroadcast:
				manager.sendWithListenBroadcast(etEnterPhoneNumber.getText()
						.toString(), etEnterMessage.getText().toString());
				break;
			}
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.send_sms);
		etEnterMessage = (EditText) findViewById(R.id.etEnterMessage);
		etEnterPhoneNumber = (EditText) findViewById(R.id.etEnterPhoneNumber);

		((Button) findViewById(R.id.btSendSMS))
				.setOnClickListener(clickListener);

		((Button) findViewById(R.id.btSendSMSWtihListenBroadcast))
				.setOnClickListener(clickListener);

		manager = new SmsSend(getBaseContext());
		manager.registerReceiver();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		manager.unregisterReceiver();
	}

}
